<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript">
	$(document).ready(function(){
		$("#deleteConsumers").click(function(){
			if($("#no:checked").size()==0){
				alert("삭제할 게시물을 선택 하세요!");
				return;
			}
			if($("#no:checked").size()>1){
				alert("삭제할 게시물을 한개만 선택 하세요!");
				return;
			}else{
				if(confirm("삭제 하시겠습니까?")){
			 		$.ajax({
						type:"post",
						url:"deleteBoard.do",
						data:$("#delBoard").serialize(),
						dataType:"json",
						success:function(jsonData){
							$("#consumerView").html("");
							var tbody="<table border='1' cellpadding='5' width='700' id='consumerView'><thead align='center'><tr><th> 제목</th><th> 날짜</th><th> 조회수</th><th> CONTENT</th><th> 작성자 ID</th><th> 삭제</th></tr></thead><tbody align='center'>";
							$.each(jsonData,function(index,List){
								tbody+="<tr><td>"+List.title+"</td>";
								tbody+="<td>"+List.questionDate+"</td>";
								tbody+="<td>"+List.count+"</td>";
								tbody+="<td>"+List.content+"</td>";
								tbody+="<td>"+List.id+"</td>";
								tbody+="<td><input type='checkbox' id='no' name='no' value='"+List.id+"'></td></tr>";
							});
							tbody+="</tbody></table>";
							$("#consumerView").html(tbody);
						} // success
					}); // ajax
				} //if
			} // else
		}); //click 
	}); //ready
</script>

<h3>게시판 관리</h3>
관리자는 부적합한 게시글을 삭제할 수 있습니다.

	<form id="delBoard">
	<br>
	<table border="1" cellpadding="5" width="700" id="consumerView">
		<thead align="center">
			<tr>
				<th>제목</th>
				<th>내용</th>
				<th>날짜</th>
				<th>조회수</th>
				<th>작성자</th>
				<th>삭제</th>
			</tr>
		</thead>
		<tbody align="center">
			<c:forEach var="list" items="${requestScope.qvo}">		
				<tr>
					<td>${list.title }</td>
					<td>${list.content }</td>
			    	<td>${list.questionDate }</td>										
					<td>${list.count }</td>
					<td>${list.id }</td>
					<td><input type="checkbox" id="no" name="no" value="${list.no }"></td>
				</tr>		
			</c:forEach>
		</tbody>
	</table>
	</form>
	<br>
	<input type="button" id="deleteConsumers" value="삭제하기">
